#ifdef __cplusplus
extern "C"{
#endif
#ifndef __XS_MALLOC_H__
#define __XS_MALLOC_H__

//#include "xs_def.h"
#include <string.h>
#include <stdlib.h>
#define __XS_MEMORY_LABEL__
extern void* __xs_malloc(int size, const char* file, int line);
extern void* __xs_zalloc(int size, const char* file, int line);
extern char* __xs_strdup(const char* ss, const char* file, int line);
extern void __xs_free(void* ptr, const char* file, int line);
extern void *__xs_calloc(size_t nmemb, size_t size, const char* file, int line);
#if 0
extern void* __xs_realloc(void* ptr, int size, const char* file, int line);
#endif

#define xs_malloc(size) __xs_malloc(size, __FILE__, __LINE__)
#define xs_zalloc(size) __xs_zalloc(size, __FILE__, __LINE__)
#define xs_strdup(ss) __xs_strdup(ss, __FILE__, __LINE__)
#define xs_calloc(a, b) __xs_calloc(a, b, __FILE__, __LINE__)
//#define xs_realloc(ptr, _size) __xs_realloc(ptr, _size, __FILE__, __LINE__)
#define xs_free(ptr) __xs_free(ptr, __FILE__, __LINE__)

#if 1
#ifndef xs_malloc
#define xs_malloc malloc
#endif

#ifndef xs_free
#define xs_free free
#endif

#ifndef xs_realloc
#define xs_realloc realloc
#endif

#ifndef xs_calloc
#define xs_calloc calloc
#endif
#endif

#ifdef USE_SYS_MALLOC
#define XS_FREE_FUNCTION  		sys_free
#define XS_MALLOC_FUNCTION  	sys_malloc
#define XS_REALLOC_FUNCTION  	sys_realloc
#define XS_CALLOC_FUNCTION  	sys_calloc
#else
#define XS_FREE_FUNCTION  		free
#define XS_MALLOC_FUNCTION  	malloc
#define XS_REALLOC_FUNCTION  	realloc
#define XS_CALLOC_FUNCTION  	calloc
#endif


#endif
#ifdef __cplusplus
}
#endif
